package com.doeis.minaserver.packet;

import com.doeis.minaserver.packet.Packet.PacketType;
import com.doeis.uwork.packet.GroupMsgPacket;
import com.doeis.uwork.packet.MessagePacket;
import com.doeis.uwork.packet.PrivateMsgPacket;
import com.doeis.uwork.packet.SystemPacket;

public abstract class PacketFactory {
	
	/**
	 * 在解包的时候，根据包着中的信息来生成不同的数据包
	 * @param type 数据包类型
	 * @return
	 */
	public static Packet basePacket(PacketType type){
		switch (type) {
		case info:
			return new InfoPacket();
		case message:
			return new MessagePacket();
		case groupMsg:
			return new GroupMsgPacket();
		case privateMsg:
			return new PrivateMsgPacket();
		case system:
			return new SystemPacket();
		default:
			return null;
		}
	}
	
}
